/* 接口:
    接口只能为对象指定类型
 */
interface Iperson {
    name: string;
    age: number;
    sayHi(): void
}

let iperson: Iperson = {
    name: "lily",
    age: 25,
    sayHi() {
        console.log("say hi");
    }
}

/* 类型别名:
    类型别名即可以给对象指定类型,
    又可以为任意类型指定别名 
*/
type IIperson = {
    name: string;
    age: number;
    sayHi(): void
}

let iiperson: IIperson = {
    name: "lily",
    age: 25,
    sayHi() {
        console.log("say hihi");
    }
}

type newType = number | string;
let newType: newType = 123;
console.log("newType:", newType);
// *****************************************

/* 
    接口的继承:
        使用 extends 继承来实现复用
*/

interface point2D {
    x: number;
    y: number
}

interface point3D extends point2D {
    z: number
}

let p3: point3D = {
    x: 1,
    y: 2,
    z: 3
}